package com.scott.po;

import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 系统菜单
 * Created by Scott on 2017/3/22.
 */
@Entity
public class SysMenu extends BaseEntity {

    private String menuName;

    private String url;

    /**
     * 父菜单
     */
    @JsonIgnore
    @ManyToOne
    @JoinColumn(name="parent_id")
    private SysMenu parent;

    /**
     * 子菜单
     */
    @OneToMany(cascade=CascadeType.ALL,fetch= FetchType.LAZY)
    @JoinColumn(name="parent_id")
    private Set<SysMenu> children = new HashSet<>();

    public String getMenuName() {
        return menuName;
    }

    public void setMenuName(String menuName) {
        this.menuName = menuName;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }


    public SysMenu getParent() {
        return parent;
    }

    public void setParent(SysMenu parent) {
        this.parent = parent;
    }

    public Set<SysMenu> getChildren() {
        return children;
    }

    public void setChildren(Set<SysMenu> children) {
        this.children = children;
    }

    public String getLabel() {
        return this.getMenuName();
    }

    public String getValue() {
        return super.getId();
    }

    public String getKey() {
        return super.getId();
    }
}
